<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
			$(function() {
				$(".date").datepicker({
					showWeek : true,
					firstDay : 1,
					dateFormat : 'yy-mm-dd',
					showOtherMonths : true,
					selectOtherMonths : true,
				});

				$("form").Validform({
					ajaxPost : true,
					tiptype : ValidUtils.siblingTip,
					callback : function(data) {
						helper.showMsg(data, {
							okHandler : function() {
								location = "../log/viewLogByTime?id=" + data.id;
							}
						});
					}
				});
				$('#term_select_menu li a').click(function(e) {
					var v = $(this).text();
					changeTermVal(v);
				});

				$('#times_select_menu li a').click(function(e) {
					var v = $(this).text();
					$(':input[name=times]').val(v);
					return true;
				});

				$(':input[name=beginTime]').change(changeEndTime);

				var oldvalue = $(':input[name=term]').val();
				$(':input[name=term]').keyup(function() {
					var v = $(':input[name=term]').val();
					if (v && v != oldvalue) {
						oldvalue = v;
						changeEndTime();
					}
				});

				$(':input[name=term],:input[name=times]').keydown(function(e) {
					var code = e.which;
					if (!e.shiftKey && (code == 8 || (code > 47 && code < 58))) {
						return true;
					} else {
						return false;
					}
				});

				function changeTermVal(val) {
					$(':input[name=term]').val(val);
					changeEndTime();
				}

				function changeEndTime() {
					var btime = $(':input[name=beginTime]').val();
					if (btime) {
						var timepart = btime.split('-');

						var mt = $(':input[name=term]').val();

						var flag = 0;

						var month = parseInt(timepart[1]) + parseInt(mt);
						if (month > 12) {
							flag = parseInt(month / 12);
							month = month % 12;
						}
						var year = parseInt(timepart[0]) + flag;

						$(':input[name=endTime]').val(year + '-' + month + '-' + timepart[2]);
					}
				}
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<s:url value="dosignUp" var="create_log"></s:url>
		<form class="form-horizontal" action="${create_log }">
			<input name="id" value="${student.id}" type="hidden" />
			<div class="row-fluid">
				<div class="span6">
					<fieldset>
						<legend>学员报名表</legend>
						<table class="table">
							<caption>
								内部编号：${student.no}，学号 ：${student.stuId},
								<s:url id="viewLogByTime" action="viewLogByTime" namespace="/log">
									<s:param name="id" value="#student.id"></s:param>
								</s:url>
								<a href="${viewLogByTime}">档案详情</a>
							</caption>
							<tr>
								<th>中文姓名</th>
								<td>${student.name}</td>
								<th>英文姓名</th>
								<td>${student.title}</td>
								<td rowspan="3">照片</td>
							</tr>
							<tr>
								<th>性别</th>
								<td>${student.sex}</td>
								<th>出生日期</th>
								<td><s:date name="#student.birthday" format="yyyy-MM-dd" /></td>
							</tr>
							<tr>
								<th>身份证号</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>学号</th>
								<td></td>
								<th>听课证号</th>
								<td colspan="2"></td>
							</tr>
							<tr>
								<th>电话</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>地址</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>Email</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>课程顾问</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>指导老师</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>注册课程</th>
								<td colspan="3"></td>
							</tr>
							<tr>
								<th>开始级别</th>
								<td colspan="3">机测<input type="text" class="input-mini" />级 <span>口测<input type="text" class="input-mini" />级
								</span>
								</td>
							</tr>
							<tr>
								<th>学习时间</th>
								<td colspan="3">共<input type="text" class="input-mini" />个月
								</td>
							</tr>
							<tr>
								<th>学习期限</th>
								<td colspan="3">从<input type="text" class="input-mini" />至<input type="text" class="input-mini" />
								</td>
							</tr>
							<tr>
								<th>学习次数（贵宾卡填写）</th>
								<td colspan="3">共<input type="text" class="input-mini" />次，卡号<input type="text" class="input-mini" />
								</td>
							</tr>
							<tr>
								<th>课时数（一对一填写）</th>
								<td colspan="3">中教<input type="text" class="input-mini" />课时\外教<input type="text" class="input-mini" />课时，卡号<input type="text" class="input-mini" />
								</td>
							</tr>
							<tr>
								<th>备注</th>
								<td colspan="3"></td>
							</tr>
						</table>
					</fieldset>
				</div>
				<div class="span6">
					<fieldset>
						<legend>签单信息</legend>
						<div class="control-group">
							<div class="control-label">
								学号 <span class="text-error">*</span>
							</div>
							<div class="controls">
								<input type="text" name="stuId" value="${student.stuId}" dataType="required" /> <span class="Validform_checktip"></span>
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">
								姓名<span class="text-error">*</span>
							</div>
							<div class="controls">
								<input type="text" value="${student.name}" /> <span class="Validform_checktip"></span>
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">课程顾问</div>
							<div class="controls">
								<select name="consultantId">
									<s:iterator value="consultants" var="consultant">
										<option value="${consultant.id}" <s:if test="id == #student.consultor.id">selected="selected"</s:if>>${ consultant.name}</option>
									</s:iterator>
								</select>
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">备注</div>
							<div class="controls">
								<textarea name="note" rows="note" cols="3"></textarea>
							</div>
						</div>
						<div class="control-group">
							<label class="checkbox controls">
								<input type="checkbox" <s:if test='#signCourseLog.book=="教材已发放"'>checked="checked"</s:if> name="book" value="教材已发放" />教材已发放
							</label>
						</div>

						<div class="control-group">
							<div class="control-label">选择课程</div>
							<div class="controls">
								<s:select list="courses" listKey="id" listValue="name" name="courseId" size="courses.size">
								</s:select>
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">合同号</div>
							<div class="controls">
								<input type="text" value="" name="contractId" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">听课证号</div>
							<div class="controls">
								<input type="text" name="lessonCard" value="" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">划次卡号</div>
							<div class="controls">
								<input type="text" name="cardId" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">期限</div>
							<div class="controls">
								<div class="input-prepend input-append">
									<div class="btn-group">
										<button class="btn dropdown-toggle" data-toggle="dropdown">
											<span class="caret"></span>
										</button>
										<ul class="dropdown-menu" id="term_select_menu">
											<li><a href="javascript:void(0)">12</a></li>
											<li><a href="javascript:void(0)">11</a></li>
											<li><a href="javascript:void(0)">10</a></li>
											<li><a href="javascript:void(0)">9</a></li>
											<li><a href="javascript:void(0)">8</a></li>
											<li><a href="javascript:void(0)">7</a></li>
											<li><a href="javascript:void(0)">6</a></li>
											<li><a href="javascript:void(0)">5</a></li>
											<li><a href="javascript:void(0)">4</a></li>
											<li><a href="javascript:void(0)">3</a></li>
										</ul>
									</div>
									<input name="term" class="span9" type="text" value="12"> <span class="add-on">个月</span>
								</div>
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">开课日期</div>
							<div class="controls">
								<input class="date" type="text" name="beginTime" value="${begin}" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">结课日期</div>
							<div class="controls">
								<input type="text" name="endTime" value="${end}" readonly="readonly" />
							</div>
						</div>
						<div class="control-group">
							<div class="control-label">课次</div>
							<div class="controls">
								<div class="input-prepend input-append">
									<div class="btn-group">
										<button class="btn dropdown-toggle" data-toggle="dropdown">
											<span class="caret"></span>
										</button>
										<ul class="dropdown-menu" id="times_select_menu">
											<li><a href="javascript:void(0)">无限次</a></li>
											<li><a href="javascript:void(0)">10</a></li>
											<li><a href="javascript:void(0)">20</a></li>
											<li><a href="javascript:void(0)">50</a></li>
											<li><a href="javascript:void(0)">100</a></li>
											<li><a href="javascript:void(0)">200</a></li>
										</ul>
									</div>
									<input name="times" class="span9" type="text" value="无限次"> <span class="add-on">&nbsp;&nbsp;次&nbsp;</span>
								</div>
							</div>
						</div>
					</fieldset>
					<div class="control-group">
						<div class="controls">
							<button type="submit" class="btn btn-primary">
								<i class="icon-ok icon-white"></i>注册
							</button>
						</div>
					</div>
				</div>
			</div>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>